package com.mao.swagger.config;

import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import springfox.documentation.builders.PathSelectors;
import springfox.documentation.builders.RequestHandlerSelectors;
import springfox.documentation.service.ApiInfo;
import springfox.documentation.service.Contact;
import springfox.documentation.spi.DocumentationType;
import springfox.documentation.spring.web.plugins.Docket;

import java.util.ArrayList;

/**
 * @author 小毛同学
 * @version 1.0
 * @data 2022/1/2 13:09
 */

/**
 *                Swagger3 的 信息配置
 */

@Configuration
public class SwaggerConfig {

    @Bean
    public Docket docket(){
        return new Docket(DocumentationType.OAS_30)
                .apiInfo(apiInfo())
                .enable(true)   // 开关
                .select()
                // .apis(RequestHandlerSelectors.basePackage("com.mao.swagger.controller"))
                // 配置扫描接口的方式
                // .paths(PathSelectors.ant(""))
                .build().groupName("分组");  // 设置分组


    }
    /**
     * 配置swagger 的 ApiInfo
     * @return ApiInfo
     */
    @Bean
    public ApiInfo apiInfo(){
        return new ApiInfo(
                "mao",
                "Java",
                "3.0",
                "https://www.baidu.com/",
                new Contact("mao", "https://www.baidu.com/", "2168975134@qq.com"),
                "Apache 2.0",
                "http://www.apache.org/licenses/LICENSE-2.0",
                new ArrayList());
    }
}
